<?php

$cates = get_category();
$article = get_article($s_aid);

$s_cate_name = "";
foreach ($cates as $cate) {
	if ($cate['id'] == $article['id_category']) {
		$s_cate_name = $cate['name'];break;
	}
}

$s_html_title = "";

if ($s_cate_name == "")
	$s_html_title = get_sys_info('sitename');
else
	$s_html_title = get_sys_info('sitename') . ' - ' . $s_cate_name;

$nread = strval(get_nread_art($article['guid']));
$cur_user = get_user_info($username);
?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<link href="./plugins/ueditor/third-party/SyntaxHighlighter/shCoreDefault.css" rel="stylesheet" type="text/css" />  
	<link type="text/css" rel="stylesheet" href=<?php  print("\"./themes/" . $cur_theme . "/css/init.css\""); ?> />
	<link type="text/css" rel="stylesheet" href=<?php  print("\"./themes/" . $cur_theme . "/css/layout.css\""); ?> />
	<link type="text/css" rel="stylesheet" href=<?php  print("\"./themes/" . $cur_theme . "/css/mods.css\""); ?> />
	<link type="text/css" rel="stylesheet" href=<?php  print("\"./themes/" . $cur_theme . "/css/login_dialog.css\""); ?> />
	<link type="text/css" rel="stylesheet" href=<?php  print("\"./themes/" . $cur_theme . "/css/xearchbox.css\""); ?> />

	<script type="text/javascript" src=<?php  print("\"./themes/" . $cur_theme . "/js/jquery.min.js\""); ?>></script>
	<script type="text/javascript" src="./plugins/ueditor/third-party/SyntaxHighlighter/shCore.js"></script>
    <script type="text/javascript" charset="utf-8" src="./plugins/ueditor/ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="./plugins/ueditor/ueditor.all.min.js"> </script>
    <script type="text/javascript" charset="utf-8" src="./plugins/ueditor/lang/zh-cn/zh-cn.js"></script>
	<script type="text/javascript" src=<?php  print("\"./themes/" . $cur_theme . "/js/jquery.SuperSlide.2.1.js\""); ?>></script>
	<script type="text/javascript" src=<?php  print("\"./themes/" . $cur_theme . "/js/xearchbox.js\""); ?>></script>
	<script type="text/javascript" src=<?php  print("\"./themes/" . $cur_theme . "/js/login_dialog.js\""); ?>></script>

	<style type="text/css"> 
	body{color:#555;font-size:14px;padding:0;margin:0;}
	#form_editor { background: #dedede; width: 100%; margin: auto; padding-top: 0px; padding-bottom: 0px;}
	#form_header { width: 100%;height: auto;margin-left:0px;margin-right:0px;border: solid black 1px;padding: 0px;}
	#content { width: 1150px;height:150px;margin: 0;padding:0px; resize: none; border: 0px;}
	#form_footer { width: 100%;height: 28px;line-height:28px;margin-left:0px;margin-right:0px;border: solid black 1px;padding: 0px;overflow: hidden;}
	#right_footer {float:right;}
	#left_footer {float:left;}
	#wrap_comments{margin: auto;padding: 0;width:1152px;};
	.cls_wrap_comments { background: #dedede; width: 1152px; margin: auto; padding-top: 16px; padding-bottom: 16px;}
	.cls_wrap_comments_table { background: green; width: 1152px; margin: 0px; padding: 0px; border: 0px;border-collapse:collapse;border: solid black 1px;}
	.cls_wrap_avatar {background: lightblue;width: 190px;height: auto;border: solid black 1px;vertical-align:top;text-align:center;}
	.cls_wrap_floor {background: white; width: 960px; height: 24px;}
	.cls_wrap_comment {background: white; width: 960px;height: auto;border: solid black 0px;word-wrap:break-word;word-break:break-all;overflow:hidden;padding: 16px;}
	.cls_wrap_ctrlpannel {background: white; width: 960px;height: 24px;border: solid black 0px;overflow:hidden;padding:0;margin:0;vertical-align:bottom;}
	#page_navigation {
		margin: auto;
		padding: 0;
		width:1152px;
		padding-top: 16px;
		padding-bottom: 16px;
		text-align: center;
	}
	#page_navigation a{
		padding:3px;
		border:1px solid gray;
		margin:2px;
		color:black;
		text-decoration:none
	}
	.active_page{
		background:darkblue;
		color:white !important;
	}
	</style>
	
    <title><?php print($s_html_title); ?></title>
  </head>
  <body>
	<!-- 登陆框什么的 开始 -->

	<div class="cd-user-modal" style="z-index:9999;"> 
	  <div class="cd-user-modal-container">
		<ul class="cd-switcher">
		  <li><a href="">用户登录</a></li>
		  <li><a href="">注册新用户</a></li>
		</ul>

		<div id="cd-login"> <!-- 登录表单 -->
		  <form class="cd-form">
			<p class="fieldset">
			  <label class="image-replace cd-username" for="signin-username">用户名</label>
			  <input class="full-width has-padding has-border" id="username" type="text" placeholder="输入用户名">
			</p>

			<p class="fieldset">
			  <label class="image-replace cd-password" for="signin-password">密码</label>
			  <input class="full-width has-padding has-border" id="password" type="password"  placeholder="输入密码">
			</p>

			<p class="fieldset">
			  <input type="checkbox" id="remember-me" checked>
			  <label for="remember-me">记住登录状态</label>
			</p>

			<p class="fieldset">
			  <input class="full-width2" type="submit" value="登 录" id="btn_sub_login">
			</p>
		  </form>
		</div>
		
		<div id="cd-signup"> <!-- 注册表单 -->
		  <form class="cd-form" action="services/signup.php" method="post">
			<p class="fieldset">
			  <label class="image-replace cd-username" for="signup_username">用户名</label>
			  <input class="full-width has-padding has-border" id="signup_username" name="signup_username" type="text" placeholder="输入用户名">
			</p>

			<p class="fieldset">
			  <label class="image-replace cd-email" for="signup_email">邮箱</label>
			  <input class="full-width has-padding has-border" id="signup_email" name="signup_email" type="email" placeholder="输入mail">
			</p>

			<p class="fieldset">
			  <label class="image-replace cd-password" for="signup_password">密码</label>
			  <input class="full-width has-padding has-border" id="signup_password" name="signup_password" type="password"  placeholder="输入密码">
			</p>

			<p class="fieldset">
			  <label class="image-replace cd-password" for="signup_repassword">密码</label>
			  <input class="full-width has-padding has-border" id="signup_repassword" name="signup_repassword" type="password"  placeholder="确认密码">
			</p>

			<p class="fieldset">
			  <input type="checkbox" id="accept_terms">
			  <label for="accept_terms">我已阅读并同意 <a href="">用户协议</a></label>
			</p>

			<p class="fieldset">
			  <input class="full-width2" type="submit" value="注册新用户" id="btn_sub_signup">
			</p>
		  </form>
		</div>

	  </div>
	</div>

	<script  type="text/javascript">
	$(document).ready(function(){

		$("#btn_sub_login").die().live("click", function( event ) {
			event.preventDefault();
			$.post("./services/login.php",{username : $("#username").val(), password : $("#password").val()}, function(data){
				if(data.status == 0){
					$(".cd-user-modal").removeClass('is-visible');
					var s_menu = "";
					s_menu = "<h3><a target=\"_blank\" href=\"";
					s_menu += "uc.php?username=" + data.rtn_username + "\"" +  ">" + data.rtn_username + "<i></i></a></h3>";
					s_menu += "				<ul>";
					s_menu += "<li><a href=\"msg.php?username=" + data.rtn_username + "\">消息<span>1000</span></a></li>";
					s_menu += "<li><a href=\"logout.php\"  id=\"exit_login\">退出</a></li>";
					s_menu += "</ul>";
					$("#menu_item_login").empty();
					$("#menu_item_login").append(s_menu);
					var s_avatar = '';
					s_avatar += "	<div style=\"padding-top:24px;\">                                              "; 	
					s_avatar += "	  <img width=\"128\" height=\"128\" src=\"" + data.rtn_avatar + "\" />  "; 	
					s_avatar += "	</div>																		   "; 	
					s_avatar += "	<div style=\"padding-top:16px;padding-bottom:16px;\">						   "; 	
					s_avatar += "	  当前用户：" + data.rtn_username; 	
					s_avatar += "	</div>																		   "; 	
					s_avatar += "	<div style=\"padding-top:16px;padding-bottom:16px;\">						   "; 	
					s_avatar += data.rtn_intro; 	
					s_avatar += "	</div>		  																   "; 	
					$("#wrap_reply_avatar").empty();
					$("#wrap_reply_avatar").append(s_avatar);
				} else {
					alert("登录失败！请重新输入！");
				}
 			}, 'json');
		});
		
		$("#exit_login").die().live("click", function(event) {
			event.preventDefault();
			$.get("services/logout.php","",function(data){
				if(data == "OK"){
					var s_menu = "";
					s_menu += "<nav class=\"main_nav\"><h3>";
					s_menu += "<a class=\"cd-signin\" href=\"#0\" style=\"color: orange;\">登录/注册</a> </h3></nav>";
					$("#menu_item_login").empty();
					$("#menu_item_login").append(s_menu);
					var s_avatar = '';
					s_avatar += "	<div style=\"padding-top:24px;\">                                              "; 	
					s_avatar += "	  <img width=\"128\" height=\"128\" src=\"/xblog/upload/avatar/nologin.jpg\" />  "; 	
					s_avatar += "	</div>																		   "; 	
					s_avatar += "	<div style=\"padding-top:16px;padding-bottom:16px;\">						   "; 	
					s_avatar += "	  当前用户：<span style=\"color:red;\">尚未登录</span>							   "; 	
					s_avatar += "	</div>																		   "; 	
					s_avatar += "	<div style=\"padding-top:16px;padding-bottom:16px;\">						   "; 	
					s_avatar += "	  当前用户尚未登录，<br/>不能发言回复！											   "; 	
					s_avatar += "	</div>		  																   "; 	
					$("#wrap_reply_avatar").empty();
					$("#wrap_reply_avatar").append(s_avatar);
				}
			});
		});

		$("#btn_sub_signup").die().live("click", function(event) {
			event.preventDefault();
			if (document.getElementById("accept_terms").checked == false) {
				alert("请先阅读并同意《用户协议》，然后继续注册！");
				return false;
			}
			if (document.getElementById("signup_password").value != document.getElementById("signup_repassword").value) {
				alert("两次输入的密码不一致，请重新输入！");
				return false;
			}
			
			$.post("services/signup.php",{
				signup_username:$("#signup_username").val(),
				signup_email:$("#signup_email").val(),
				signup_password:$("#signup_password").val()
			}, function(data){
				if (data.status == 0) {
					$(".cd-user-modal").removeClass('is-visible');
					var s_menu = "";
					s_menu = "<h3><a target=\"_blank\" href=\"";
					s_menu += "uc.php?username=" + data.rtn_username + "\"" +  ">" + data.rtn_username + "<i></i></a></h3>";
					s_menu += "				<ul>";
					s_menu += "<li><a href=\"msg.php?username=" + data.rtn_username + "\">消息<span>1000</span></a></li>";
					s_menu += "<li><a href=\"logout.php\"  id=\"exit_login\">退出</a></li>";
					s_menu += "</ul>";
					$("#menu_item_login").empty();
					$("#menu_item_login").append(s_menu);
					var s_avatar = '';
					s_avatar += "	<div style=\"padding-top:24px;\">                                              "; 	
					s_avatar += "	  <img width=\"128\" height=\"128\" src=\"" + data.rtn_avatar + "\" />  "; 	
					s_avatar += "	</div>																		   "; 	
					s_avatar += "	<div style=\"padding-top:16px;padding-bottom:16px;\">						   "; 	
					s_avatar += "	  当前用户：" + data.rtn_username; 	
					s_avatar += "	</div>																		   "; 	
					s_avatar += "	<div style=\"padding-top:16px;padding-bottom:16px;\">						   "; 	
					s_avatar += data.rtn_intro; 	
					s_avatar += "	</div>		  																   "; 	
					$("#wrap_reply_avatar").empty();
					$("#wrap_reply_avatar").append(s_avatar);
				} else {
					if (data.status == -1) {
						alert("注册失败！当前已登录，请先退出当前登录，然后注册！");
					}
					if (data.status == -2) {
						alert("注册失败！注册信息填写不完整，请完善！");
					}
					if (data.status == -3) {
						alert("注册失败！服务器端操作数据库失败，或者该用户名已经被注册，请联系管理员以解决相关问题！");
					}
				}
 			}, 'json');
		});
		
	});
	
	</script>
	
	<!-- 登陆框什么的 结束 -->
	
	<a name="head"></a>
    <div id="area_head">
      <div id="area_head_center">
		<div id="mod_logo"><a href="/"></a></div>
		<div id="area_head_left">
		  <div id="wrap_ad_top"></div>
		  <div class="cls_main_menu">
			<dl class="turn_right">
			  <dd>
				<h3><a href="index.php">首页</a></h3>
			  </dd>
			  <?php
			  foreach ($cates as $cate) {
				  if (trim(strval($cate['id'])) == trim(strval($article['id_category']))) {
					  print(
						  "<dd><h3>" . "<a href=\"category.php?id=" . $cate['id'] . "\"" .
							  "class=\"cls_cur_menu_item\">" .$cate['name'] . "</a>" . "</h3></dd>"
					  );
				  } else {
					  print(
						  "<dd><h3>" . "<a href=\"category.php?id=" .
							  $cate['id'] . "\">" .$cate['name'] . "</a>" . "</h3></dd>"
					  );
				  }
			  }
			  ?>
			  <dd   id="menu_item_login">
				<?php
				$s_menu = "<h3><a target=\"_blank\" href=\"";
				if ($username != "") {
					$s_menu .= "uc.php?username={$username}\"" .  ">" . $username . "<i></i></a></h3>";
					$s_menu .= "				<ul>";
					$s_menu .= "<li><a href=\"msg.php?username={$username}\">消息<span>2000</span></a></li>";
					$s_menu .= "<li><a href=\"logout.php\" id=\"exit_login\">退出</a></li>";
					$s_menu .= "</ul>";
				} else {
					$s_menu = "<nav class=\"main_nav\"><h3>";
					$s_menu .= "<a class=\"cd-signin\" href=\"#0\" style=\"color: orange;\">登录/注册</a> </h3></nav>";
				}
				print($s_menu);
				?>
			  </dd>
			  <dd>
				<h3><a href="about.php" target="_blank">关于</a></h3>
			  </dd>
			  <dd>
				<h3><input type="text" id="search_box" style="height:24px;line-height:24px;width:0px;margin:4px;padding:0;text-indent:8px;border:0; vertical-align:middle;" /></h3>
			  </dd>
			  <dd id="search_starter" style="background: url('./themes/default/img/icon-search.png') no-repeat;background-color:black;width:32px;height:32px;dispaly:inline;font-size:12px;background-position: center;">
			  </dd>
			</dl>
		  </div>
		  <script type="text/javascript">
		  jQuery(".cls_main_menu").slide({ type:"menu",  titCell:"dd", targetCell:"ul", delayTime:0,defaultPlay:false,returnDefault:true  });	
		  </script>
		  <script type="text/javascript">

		  $(document).ready(function(){

			  $("#search_starter").die().live("click", function(e){
				  if ($("#search_box").css("width") == "0px") {
					  $("#search_box").animate({width:"128px"});
				  } else {
					  if ($("#search_box").attr("value").trim() != "") {
						  alert($("#search_box").attr("value"));
					  } else {
						  $("#search_box").animate({width:"0px"});
					  }
				  }
			  });
			  
		  });
		  
		  $("#search_box").die().live("keypress", function(e) {
			  if(e.which == 13) { 
				  jQuery("#search_starter").click(); 
			  }
		  });
		  
		  </script>
		</div>
      </div>
    </div>
    <div id="area_head_bottom"> </div>
	
    <div id="area_body">

	  <!-- ------------------------------------------------ -->
	  <table class="cls_wrap_comments_table">
		<tr>
		  <td rowspan=3 class="cls_wrap_avatar" style="border:solid black 1px;background:white;color black;">
			<?php
			$s_avatar_path = get_avatar_user($article['username']);
			$user_art = get_user_info($article['username']);
			$s_user_intro = "";
			$s_user_intro = $user_art['introduction'];
			$s_html = <<<EOT
			<div style="padding-top:24px;">
			  <img width="128" height="128" src="{$s_avatar_path}" />
			</div>
			<div style="padding-top:16px;padding-bottom:16px;">
			  {$article['username']}
			</div>
			<div style="padding-top:16px;padding-bottom:16px;">
			  {$s_user_intro}
			</div>
			<div style="padding-top:16px;padding-bottom:16px;">
			  <a href="mailto:{$user_art['email']}">发送邮件</a> 或者
			  <a href="{$user_art['homepage']}" target="_blank" >访问主页</a>
			</div>
EOT;
			print($s_html);
			?>
		  </td>
		</tr>
		<tr>
		  <td class="cls_wrap_comment">
			<div style="margin-top:16px;"  id="wrap_article">
			  <h1 style="text-align:center;font-size:32px;padding-bottom:32px;"><?php print($article['title']); ?></h1>
			  <?php
			  print("<div class=\"article-info\" style=\"padding-bottom:16px;text-align:center;\">");
			  print("作者：<a href=\"./author.php?name={$article['username']}\" class=\"article-author\" target=\"_blank\">{$article['username']}</a>&nbsp;&nbsp;");
			  print("发表于：<span class=\"tm\">{$article['maketime']}&nbsp;&nbsp;</span>");
			  print("<span class=\"count\">阅读：{$nread} 次</span></div>");

			  print("<div style=\"background-color:#eeeeee;padding-bottom:16px;padding-top:16px;padding-left:16px;padding-right:8px;	line-height:normal;font-size:14px;\">");
			  print($article['intro']);
			  print("</div><br />");
			  print("<div class=\"art_content\"  id=\"article_{$article['guid']}\">");
			  print($article['content']);
			  print("</div><br />");
			  ?>
			  <div style="height:100%;width:100%;display:none;padding-top:32px;text-align:center;" id="wrap_mob_editor">
				<script id="mob_editor" type="text/plain" style="width:100%;height:150px;"></script>
				<intpu type="hidden" value="" id="cur_view"/>
				<input style="margin-top:16px;" type="button" value="提交回复" id="btn_sub_mob_editor"/>
			  </div>

			</div>
		  </td>
		</tr>
		
		<tr>
		  <td class="cls_wrap_ctrlpannel">
			  <?php
			  $s_opsnum = strval(get_attitude_article_number($s_aid, 'oppose'));
			  $s_sptnum = strval(get_attitude_article_number($s_aid, 'support'));
			  print("<div style=\"background:silver;border: black solid 1px;height:24px;line-height:24px;\">");
			  print("<div style=\"float: left;color: black;\">");
			  print(" <a href=\"./alert.php?t=a&id={$article['guid']}\" target=\"_blank\" > 举报</a>");
			  print("</div>");
			  print("<div style=\"float: right;color: black;\">");
			  print("<a href=\"\" id=\"aid_support_{$s_aid}\" class=\"cls_reply\">支持</a>");
			  print("(<span id=\"aid_support_{$s_aid}_num\">{$s_sptnum}</span>次)&nbsp;&nbsp;&nbsp;&nbsp;");
			  print("<a href=\"\" id=\"aid_oppose_{$s_aid}\" class=\"cls_reply\">反对</a>");
			  print("(<span id=\"aid_oppose_{$s_aid}_num\">{$s_opsnum}</span>次)&nbsp;&nbsp;&nbsp;&nbsp; ");
			  print("<a href=\"\" id=\"aid_replay_{$s_aid}\" class=\"cls_reply\">回复</a>");
			  print("</div>");
			  print("</div>");
			  ?>
		  </td>
		</tr>
		
	  </table>
	</div>

	<script type="text/javascript">

	// 创建活动编辑器
	var uem = UE.getEditor('mob_editor',{
		initialFrameWidth :930,//设置编辑器宽度
		initialFrameHeight:150,//设置编辑器高度
		scaleEnabled:false
	});

	$(document).ready(function(){
		$(".cls_reply").die().live("click", function(e){
			e.preventDefault();
			var req = e.target.id.split('_');
			if (req[0] == 'aid') {
				if (req[1] == 'support') {
					$.post("./services/new_attitude.php",{val : "支持", id : req[2]}, function(data){
						if (data.errno == 0) {
							$("#" + e.target.id + "_num").text( parseInt($("#" + e.target.id + "_num").text()) + 1 );
						} else {
							alert("执行操作时发生错误，请查看网络连接是否正常，或者联系管理员。错误号：" + data.errno);
						}
					}, 'json');
				} else if (req[1] == 'oppose') {
					$.post("./services/new_attitude.php",{val : "反对", id : req[2]}, function(data){
						if (data.errno == 0) {
							$("#" + e.target.id + "_num").text( parseInt($("#" + e.target.id + "_num").text()) + 1 );
						} else {
							alert("执行操作时发生错误，请查看网络连接是否正常，或者联系管理员。错误号：" + data.errno);
						}
					}, 'json');
				} else {
					if ($("#cur_view").val() != req[2]) {$("#cur_view").val('a_' + req[2]);}
					if ( $("#wrap_mob_editor").is(":visible")) {
						$("#wrap_mob_editor").css("display","none");
					} else {
						$("#wrap_mob_editor").insertAfter( $("#article_" + req[2]) );
						$("#wrap_mob_editor").css("display","");
					}
				}
			} else {
				if (req[1] == 'support') {
					$.post("./services/new_comment_comment.php",{attitude : "support", id : req[2]}, function(data){
						if (data.errno == 0) {
							$("#" + e.target.id + "_num").text( parseInt($("#" + e.target.id + "_num").text()) + 1 );
						} else {
							alert("执行操作时发生错误，请查看网络连接是否正常，或者联系管理员。错误号：" + data.errno);
						}
					}, 'json');
				} else if (req[1] == 'oppose') {
					$.post("./services/new_comment_comment.php",{attitude : "oppose", id : req[2]}, function(data){
						if (data.errno == 0) {
							$("#" + e.target.id + "_num").text( parseInt($("#" + e.target.id + "_num").text()) + 1 );
						} else {
							alert("执行操作时发生错误，请查看网络连接是否正常，或者联系管理员。错误号：" + data.errno);
						}
					}, 'json');
				} else {
					if ($("#cur_view").val() != req[2]) {$("#cur_view").val('c_' + req[2]);}
					if ( $("#wrap_mob_editor").is(":visible")) {
						$("#wrap_mob_editor").css("display","none");
					} else {
						$("#wrap_mob_editor").insertAfter( $("#comment_" + req[2]) );
						$("#wrap_mob_editor").css("display","");
					}
				}
			}
		});
	});

	$(function(){ 
		$("#btn_sub_mob_editor").click(function(){
			var s_pre = '';
			var a = $("#cur_view").val().split('_');

			if (a[0] == 'c') {
				s_pre = '回复&nbsp;&nbsp;' + $('#floor_' + a[1]).text() + '&nbsp;&nbsp;楼：<hr />';
			}
					
			$.post("./add_comment.php",{id : $("#aid").val(), content : s_pre + uem.getContent()}, function(dat) {
				if (a[0] == 'a') {
					add_reply(dat, 'h');
				} else {
					add_reply(dat, a[1]);
				}
			}, 'html'); 
		});   
	});
	
	</script>

	  <!-- ----------------------- 讨论区开始 -------------------------------------- -->
	  <div style="width:1152px;background:#dedede;color:GREEN;margin:auto;padding:0;text-align:center;font-size:24px;font-weight:700;padding-top:16px;padding-bottom:16px;">
		<a name="anchor_discuss"> 讨论区郑重提醒您： 您已不小心进入雷区，小心误伤！</a>
	  </div>
  
	  <input type='hidden' id='current_page' />
	  <input type='hidden' id='show_per_page' />
	  <div id='wrap_comments'>
		<?php
		$s_html_comment = "";$rowno = 0;$s_rowno = '0';
		if ($comments) {
			foreach ($comments as $comment) {
				$rowno += 1;$s_rowno = strval($rowno);
				$s_opsnum = strval(get_attitude_comment_number($comment['guid'], 'oppose'));
				$s_sptnum = strval(get_attitude_comment_number($comment['guid'], 'support'));
				$s_html_comment = <<< EOT
				<div class="cls_wrap_comments" id="wrap_comment_{$comment['guid']}">
				
				<table class="cls_wrap_comments_table">
				<tr>
				<td rowspan=4 class="cls_wrap_avatar">
				<div style="padding-top:64px;">
				<img width="128" height="128" src="{$comment['avatar']}" />
				</div>
				<div style="padding-top:16px;padding-bottom:16px;">
				{$comment['username']}
				</div>
				</td>
				</tr>
				<tr>
				<td class="cls_wrap_floor" valign="top">
				<div style="background:yellow;height:24px;line-height:24px;border-bottom: solid black 1px;">
				<div style="float: left;color: black;height:100%;margin:0;padding:0;display:inline;">
				评论时间： {$comment['maketime']}
				</div>
				<div style="float: right;color: black;height:100%;margin:0;padding:0;display:inline;">
				楼层：第&nbsp;<span id="floor_{$comment['guid']}">{$s_rowno}</span>&nbsp;层
				</div>
				</div>
				</td>
				</tr>
				<tr>
				<td class="cls_wrap_comment">
				<div style="margin:auto;padding:0;" id="comment_{$comment['guid']}">
				{$comment['content']}
				</div>
				</td>
				</tr>
				<tr  valign="bottom">
				<td class="cls_wrap_ctrlpannel">
				<div style="background: silver;height:24px;line-height:24px;border-top: solid black 1px;">
				<div style="float: left;color: black;">
				<a href="./alert.php?t=c&id={$comment['guid']}" target="_blank" > 举报</a>
				</div>
				<div style="float: right;color: black;">
				<a href="" id="cid_support_{$comment['guid']}" class="cls_reply">支持</a>
				(<span id="cid_support_{$comment['guid']}_num">$s_sptnum</span>次)&nbsp;&nbsp;&nbsp;&nbsp;
				<a href="" id="cid_oppose_{$comment['guid']}" class="cls_reply">反对</a>
				(<span id="cid_oppose_{$comment['guid']}_num">$s_opsnum</span>次)&nbsp;&nbsp;&nbsp;&nbsp;
				<a href="" id="cid_replay_{$comment['guid']}" class="cls_reply">回复</a>
				</div>
				</div>
				</td>
				</tr>
				</table>
				
				</div>
EOT;
				print("{$s_html_comment}");
			}
		}
		?>
	  </div>
	  <div id='page_navigation' style="visibility:visible;"></div>

	  <!-- ----------------------------回复编辑区 开始 ---------------------------- -->
	  <div style="margin: auto;padding:0;width:1152px;">
	  <table class="cls_wrap_comments_table">
		<tr>
		  <td rowspan=3 class="cls_wrap_avatar" style="border:solid black 1px;background:white;color black;" id="wrap_reply_avatar">
			<?php
			if ($username != "") {
				$s_avatar_path = get_avatar_user($username);
				$username_cur = $username;
				$user_cur = get_user_info($username);
				$s_user_intro = "";
				$s_user_intro = $user_cur['introduction'];
			} else {
				$s_avatar_path = '/xblog/upload/avatar/nologin.jpg';
				$username_cur = '<span style="color:red;">尚未登录</span>';
				$s_user_intro = "当前用户尚未登录，<br/>不能发言回复！";
			}
			$s_html = <<<EOT
			<div style="padding-top:64px;">
			  <img width="128" height="128" src="{$s_avatar_path}" />
			</div>
			<div style="padding-top:16px;padding-bottom:16px;">
			  当前用户：{$username_cur}
			</div>
			<div style="padding-top:16px;padding-bottom:16px;">
			  {$s_user_intro}
			</div>
EOT;
			print($s_html);
			?>
		  </td>
		</tr>
		<tr>
		  <td class="cls_wrap_comment" style="margin:0;padding:0;background:silver;">
			<div style="margin-top:8px;padding:0;">
			  <h1 style="text-align:center;font-size:24px;padding-bottom:8px;">我有话要说</h1>
			  <div id="form_editor">
				<form action="add_comment.php" method="get" id="suggest_form">
				  <div id="form_header">
					<script id="editor" type="text/plain" style="width:100%;height:150px;"></script>
					<input type="hidden" name="content" id="content">
				  </div>
			  </div>
			</div>
		  </td>

		  <tr>
			<td class="cls_wrap_ctrlpannel">
			  <div id="form_footer">
				<div id="left_footer" style="vertical-align:middel;">
				  发言时，请遵循中华人名共和国相关法律，文明发言。
				  <input type="hidden" name="aid" id="aid" value="<?php print($s_aid); ?>" />
				</div>
				<div id="right_footer">
				  <input type="button" value="发表回复" id="btn_sub" />
				</div>
			  </div>
				</form> 
			</td>
		  </tr>

		</tr>
	  </table>
	  </div>
	  <!-- ----------------- 回复编辑区 结束 -->

	  <script type="text/javascript">
	  SyntaxHighlighter.all();
	  // -------------------------------------------------------------------------------
	  $(document).ready(function(){
		  var show_per_page = 5; 
		  var number_of_items = $('#wrap_comments').children().size();
		  var number_of_pages = Math.ceil(number_of_items/show_per_page);
		  $('#current_page').val(0);
		  $('#show_per_page').val(show_per_page);
		  var navigation_html = '<a class="previous_link" href="javascript:previous();">上一页</a>';
		  var current_link = 0;
		  while(number_of_pages > current_link){
			  navigation_html += '<a class="page_link" href="javascript:go_to_page(' + current_link +')" longdesc="' + current_link +'">'+ (current_link + 1) +'</a>';
			  current_link++;
		  }
		  navigation_html += '<a class="next_link" href="javascript:next();">下一页</a>';
		  
		  $('#page_navigation').html(navigation_html);
		  $('#page_navigation .page_link:first').addClass('active_page');
		  $('#wrap_comments').children().css('display', 'none');
		  $('#wrap_comments').children().slice(0, show_per_page).css('display', 'block');	
	  });

	  function goto_editor()
	  {
		  location.hash="anchor_discuss";
	  }
	  
	  function previous(){
		  new_page = parseInt($('#current_page').val()) - 1;
		  if($('.active_page').prev('.page_link').length==true){
			  go_to_page(new_page);
		  }
	  }
	  function next(){
		  new_page = parseInt($('#current_page').val()) + 1;
		  if($('.active_page').next('.page_link').length==true){
			  go_to_page(new_page);
		  }
	  }
	  function go_to_page(page_num){
		  var show_per_page = parseInt($('#show_per_page').val());
		  start_from = page_num * show_per_page;
		  end_on = start_from + show_per_page;
		  $('#wrap_comments').children().css('display', 'none').slice(start_from, end_on).css('display', 'block');
		  $('.page_link[longdesc=' + page_num +']').addClass('active_page').siblings('.active_page').removeClass('active_page');
		  $('#current_page').val(page_num);
	  }
	  //===========================================================================================
	  // 创建主编辑器
	  var ue = UE.getEditor('editor',{
		  initialFrameWidth :960,//设置编辑器宽度
		  initialFrameHeight:150,//设置编辑器高度
		  scaleEnabled:false
	  });

	  // 编辑器表单提交
	  $(function(){ 
		  $("#btn_sub").click(function(){
			  document.getElementById("content").value = ue.getContent();
			  $.post("./add_comment.php",{id : $("#aid").val(), content : $("#content").val()}, function(dat){
				  add_reply(dat,'f')
			  }, 'html'); 
		  });   
	  });

	  function add_reply(dat, pos)
	  {
		  var data = jQuery.parseJSON(dat);
		  if(data.errno == 0){
			  var s_comment = "";
			  s_comment += "<div class=\"cls_wrap_comments\">";
			  s_comment += "<table class=\"cls_wrap_comments_table\">";
			  s_comment += "<tr>																			    ";
			  s_comment += "	<td rowspan=3 class=\"cls_wrap_avatar\">										";
			  s_comment += "	<div style=\"padding-top:24px;\">												";
			  s_comment += "	  <img width=\"128\" height=\"128\" src=\"" + data.avatar+ "\" />				";
			  s_comment += "	</div>																			";
			  s_comment += "	<div style=\"padding-top:16px;padding-bottom:16px;\">							";
			  s_comment += "	  " + data.username + "													";
			  s_comment += "	</div>																			";
			  s_comment += "	</td>																			";
			  s_comment += "	<td class=\"cls_wrap_floor\">													";
			  s_comment += "	<div style=\"background:yellow;border-bottom:solid black 1px;height:24px;line-height:24px;\">";
			  s_comment += "	<div style=\"float: left;color: black;\">										";
			  s_comment += "	  评论时间： " + data.maketime +"												";
			  s_comment += "	</div>																			";
			  s_comment += "	<div style=\"float: right;color: black;\">										";
			  s_comment += "	  新的楼层      																	";
			  s_comment += "	</div>																			";
			  s_comment += "	</div>																			";
			  s_comment += "	</td>																			";
			  s_comment += "</tr>																				";
			  s_comment += "<tr>																				";
			  s_comment += "	<td class=\"cls_wrap_comment\">													";
			  s_comment += data.content;
			  s_comment += "	</td>																			";
			  s_comment += "</tr>																				";
			  s_comment += "<tr>																				";
			  s_comment += "	<td class=\"cls_wrap_ctrlpannel\">												";
			  s_comment += "	<div style=\"background:silver;border-top:solid black 1px;height:24px;line-height:24px;\">";
			  s_comment += "	<div style=\"float: right;color: black;\">										";
			  s_comment += "	  支持(0次)&nbsp;&nbsp;&nbsp;&nbsp; 反对(0次)&nbsp;&nbsp;    ";
			  s_comment += "	</div>																			";
			  s_comment += "	</div>																			";
			  s_comment += "	</td>																			";
			  s_comment += "</tr>																				";
			  s_comment += "</table>"
			  s_comment += "</div>"
			  if ( pos == 'h') {
				  $("#wrap_comments").prepend(s_comment); //在前面追加
				  $("#wrap_mob_editor").css("display","none");
			  } else if ( pos == 'f') {
				  $("#wrap_comments").append(s_comment); //在前面追加
			  } else {
				  $('#wrap_comment_' + pos).after(s_comment);
				  $("#wrap_mob_editor").css("display","none");
			  }
			  
		  } else if (data.errno == -1) {
			  alert("文章ID为空！");
		  } else if (data.errno == -2) {
			  alert("当前尚未登录！");
		  } else if (data.errno == -3) {
			  alert("文章内容为空！");
		  } else {
			  alert("增加评论失败，原因未知！");
		  }
	  }
	  
	  </script>
	  
	  <!-- ------------------------讨论区结束 -------------------------------------- -->
      <div id="area_space_foot"></div>

      <div id="area_foot">
		<a name="foot"></a>
		<!-- 尾部开始 -->
		<div id="footer">
		  <div class="footer_container">
			<div class="row">
              <dl class="col-sm-2 site-link">
				<dt>网站相关</dt>
				<dd><a href="javascript:void(0);" onclick="AddFavorite('符动乾坤-以结构化意识论的观点探索（人类）智能的奥秘！',location.href)">收藏本站</a></dd>
				<dd><a href="./about.php" target="_blank">关于我们</a></dd>
				<dd><a href="./tos.php" target="_blank">服务条款</a></dd>
				<dd><a href="./rss.php" target="_blank">RSS订阅</a></dd>
				<dd><a href="http://jq.qq.com/?_wv=1027&k=cNV8Y2" target="_blank">官方QQ群</a></dd>
				<dd><a href="http://online.thesct.net" target="_blank">结构化意识论</a></dd>
              </dl>
              <dl class="col-sm-2 site-link">
				<dt>联系合作</dt>
				<dd><a href="mailto:xy_god@thesct.net">站长邮箱</a></dd>
				<dd>
				  <a href='http://wpa.qq.com/msgrd?V=1&uin=908224171&Site=符动乾坤&Menu=yes' target='_blank'>
					站长之Q
				  </a>
				</dd>
				<dd><a href="/0x">建议反馈</a></dd>
				<dd><a href="<?php  print("./themes/" . $cur_theme . "/img/logo_h.png"); ?>" target="_blank">Logo下载</a>
				</dd>
              </dl>
              <dl class="col-sm-2 site-link">
				<dt>友情链接</dt>
				<dd><a href="http://git.oschina.net/" title="Git@OSC" target="_blank">Git@OSC</a></dd>
				<dd><a href="http://www.deepin.org/" title="深度操作系统" target="_blank">深度操作系统</a></dd> 	
				<dd><a href="http://www.ubuntukylin.com/" title="优麒麟" target="_blank">优麒麟</a></dd> 	
				<dd><a href="https://getfedora.org/" title="Fedora官网" target="_blank">Fedora官网</a></dd> 	
				<dd><a href="http://www.scholarnet.cn/" title="学术网" target="_blank">学术网</a></dd> 	
				<dd><a href="http://hexinbbs.blog.163.com/" title="何新网易博客" target="_blank">何新网易博客</a></dd> 	
              </dl>
              <dl class="col-sm-2 site-link">
				<dt>关注我们</dt>
				<dd><a href="http://tieba.baidu.com/f?fr=search&ie=utf-8&kw=%E7%BB%93%E6%9E%84%E5%8C%96%E6%84%8F%E8%AF%86%E8%AE%BA"
						title="结构化意识论贴吧" target="_blank">百度贴吧</a> </dd>
				<dd><a href="http://git.oschina.net/thesct" title="Git@OSC" target="_blank">Git@OSC</a></dd>
				<dd><a href="/blog/segmentfault" target="_blank">开发日志</a></dd>
              </dl>
              <dl class="col-sm-4 site-link" id="license">
				<dt>内容许可</dt>
				<dd>除特别说明外，本站内容均为原创，转载须明确标明本站出处，否则，可视为侵权，站长保留相关一切权利。
				</dd>
				<dd>
				  Copyright © 2014-2016 符动乾坤 版权所有 违者必究.
				</dd>
				<dd>
				  <a href="http://www.miibeian.gov.cn/" rel="nofollow" target="_blank">备案号：&nbsp;&nbsp;冀ICP备14018418号</a>
				</dd>
				<dd>
                  <a href="http://www.thesct.net">
					<img src="<?php  print("./themes/" . $cur_theme . "/img/logo_h.png"); ?>" width="320" height="64" />
                  </a>
				</dd>
              </dl>
			</div>
		  </div>
		</div>
		<!-- 尾部结束 -->
		<div class="clearfix"></div>
	  </div>
	  
	  <div id="indicator">
		<div id="shang" onclick="location.href='#head'"></div>
		<div id="zhong_w">
		  <div id="zhong">
			<div class="weixin">
			  <img src=<?php  print("\"./themes/" . $cur_theme . "/img/weixin.jpg\""); ?> width="150" height="150" />
			</div>
		  </div>
		</div>
		<div id="xia" onclick="location.href='#foot'"></div>
	  </div>	
	  
  </body>
</html>
